﻿#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace StarFox.ScreenComponents
{
    /// <summary>
    /// Stores all necessary information to define an small asteroid.
    /// </summary>
    public class SmallAsteroid
    {
        #region Fields

        Matrix world;

        #endregion

        #region Properties

        /// <summary>
        /// Gets the small asteroid model.
        /// </summary>
        public int Model { get; private set; }

        /// <summary>
        /// Gets the small asteroid position.
        /// </summary>
        public Vector3 Position { get; private set; }

        /// <summary>
        /// Gets the world matrix used to draw the small asteroid.
        /// </summary>
        public Matrix World
        {
            get { return world; }
        }

        #endregion

        #region Constructor

        /// <summary>
        /// Initializes a new instance of this class.
        /// </summary>
        /// <param name="model">The small asteroid model.</param>
        /// <param name="position">The small asteroid position.</param>
        public SmallAsteroid(int model, Vector3 position)
        {
            Model = model;
            Position = position;

            Vector3 rotation = new Vector3(StarFoxHelper.RandomFloat(-MathHelper.Pi, MathHelper.Pi),
                                           StarFoxHelper.RandomFloat(-MathHelper.Pi, MathHelper.Pi),
                                           StarFoxHelper.RandomFloat(-MathHelper.Pi, MathHelper.Pi));

            world = Matrix.Identity;

            // adjust rotation
            world *= Matrix.CreateRotationX(rotation.X);
            world *= Matrix.CreateRotationY(rotation.Y);
            world *= Matrix.CreateRotationZ(rotation.Z);

            // adjust translation
            world.Translation = Position;
        }

        #endregion
    }
}
